package com.novax.ex.activity.task.job;

import com.novax.ex.activity.task.executor.ScheduledFundReleaseExecutor;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class ScheduledFundReleaseJob {

    private final ScheduledFundReleaseExecutor executor;

    /**
     * 每星期三00:00执行
     */
    @XxlJob("ScheduledFundReleaseJobHandler")
    public void scheduledFundReleaseJobHandler() {
        XxlJobHelper.log("[ScheduledFundReleaseJobHandler start.]");
        val start = System.currentTimeMillis();
        try {
            executor.exec();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            XxlJobHelper.log(e);
        }

        XxlJobHelper.log("[ScheduledFundReleaseJobHandler end. {} ms]", System.currentTimeMillis() - start);
    }
}
